# Linkfile for MFR tasks $Revision: 5622 $
#
# (c) 2003, 2004 ECO_L O G Logistiksysteme GmbH, Wels

# $Id: Linkfile.mk 5622 2008-04-28 07:29:57Z mge $
# $Name$

CVERSION := $(shell gcc -v 2>&1 | grep "gcc version" | awk '{ gsub ("\\.", " ", $$3); print $$3 }')
CMAJORVERSION := $(word 1, $(CVERSION))
CMINORVERSION := $(word 2, $(CVERSION))
MACHINE := $(shell uname -m)
PROJLIBS = link.scr

ifndef CBASEFLAGS
include use_xml.mk
endif

ifndef DIRECTORIES
DIRECTORIES = l2all l2get l2anford
endif

POFILES := $(shell ls -1 po/*.po)
ORALIBS :=  -lclntsh $(shell cat $$ORACLE_HOME/lib/ldflags $$ORACLE_HOME/lib/sysliblist) -ldl -lm
TASK_OBJS = \
	auslag21.o \
	dako_mon.o \
	dumpConfig.o \
	eappkt20.o \
	einlagm.o \
	ft20.o \
	loop.o \
	msg_read.o \
	msg_remv.o \
	progpaus.o \
	queuer.o \
	qvw30.o \
	rbgkombm.o \
	sqlwcall.o \
	sqlwind.o \
	stoern.o \
	telbuch.o \

# obige Leerzeile NICHT entfernen!
#

TASK_OBJS += debug.o sqlpipe.o sqlalert.o runscript.o readChannel.o rbgkombmplus.o
TASK_LIBS = \
	libbridger.a \
	libft20.a \
	liblamkoord.a \
	libmock.a \
	librbg.a \
	librooter.a \

# obige Leerzeile NICHT entfernen!
#
#ROOTER_OBJS = \
	rooter.o \
	rooter_oracle.o \
	rooter_parse.o \
	rooter_quarry.o \

# obige Leerzeile NICHT entfernen!
# FT20-Bibliothek
FT20_OBJS = \
	ft20_globals.o \
	ft20_oracle.o \
	ft20_peripherals.o \
	ft20_strategies.o \

# obige Leerzeile NICHT entfernen!
# Inhalt der Lamkoord-Bibliothek
#LAMKOORD_OBJS = \
	lamkoord_action.o \
	lamkoord_aisle.o \
	lamkoord_controller.o \
	lamkoord_device.o \
	lamkoord_graph.o \
	lamkoord.o \
	lamkoord_oracle.o \
	lamkoord_request.o \
	lamkoord_reservation.o \

# obige Leerzeile NICHT entfernen!
# Inhalt der RBG-Bibliothek
RBG_OBJS = \
	Action.o \
	ActionFactory.o \
	CrateVisitor.o \
	DBHandler.o \
	Delegate.o \
	Depot.o \
	PortController.o \
	PortFactory.o \
	PortManager.o \
	Port.o \
	rbg_broker_dual.o \
	rbg_broker.o \
	rbg_broker_OPO2.o \
	rbg_broker_simple.o \
	rbg_cargo.o \
	rbg_crane_multi_fork.o \
	rbg_crane_multi_lz.o \
	rbg_crane.o \
	rbg_crane_OPO2.o \
	rbg_crane_OPO.o \
	rbg_crane_single_fork.o \
	rbg_device.o \
	rbg_factory.o \
	rbg_fork_kombi_2f2l.o \
	rbg_fork_multi_cargo.o \
	rbg_fork.o \
	rbg_fork_single_cargo.o \
	rbg_fork_spectra_r.o \
	rbg_fork_teleskop.o \
	rbg_fork_tel_s01.o \
	rbg_fork_twister.o \
	rbg_normalizer.o \
	rbg.o \
	rbg_oracle.o \
	rbg_SQLCommand.o \
	TeleskopDBHandler.o \

# obige Leerzeile NICHT entfernen!
#
RBGKOMBMPLUS_OBJS = RBGObject.o MfrObject.o
BRIDGER_OBJS = \
	bridger.o \
	BridgerDevice.o \
	BridgerMessageParser.o \
	BridgerMessageReceiver.o \
	BridgerMessages.o \
	BridgerP2L.o \
	BridgerWaage.o \

# obige Leerzeile NICHT entfernen!
#	
MOCKTASK_OBJS = mocktask_Command.o mocktask_parser.o mocktask.o mocktask_oracle.o
TASKS = $(TASK_OBJS:.o=) $(TASK_LIBS:lib%.a=%)
MAIN_OBJS = \
	bridger_main.o \
	mocktask_main.o \
	rbg_main.o \
#	rooter_main.o \
	lamkoord_main.o

# obige Leerzeile NICHT entfernen!
#
.SECONDARY: $(RBG_OBJS) $(BRIDGER_OBJS) $(MOCKTASK_OBJS) $(FT20_OBJS)

all:		$(TASKS) $(DIRECTORIES) empty
ifndef CBASEFLAGS
		@./convert $(POFILES)
endif
		@if type -t ccache > /dev/null ; then ccache -s ; fi

cversion:
		@echo $(CVERSION)
		@echo $(CMAJORVERSION)
		@echo $(CMINORVERSION)
		@echo $(MACHINE)

empty:
		@$(RM) `find . -maxdepth 1 -size 0`

oralibs:
		@echo $(ORALIBS)

$(TASKS):	libold.a libeco.a libmfr.a

# ----------- MFR Tasks ------------

.o:
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lold -lmfr -leco -lmfr -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

debug_old:	debug_old.o libold.a libmfr.a libeco.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lold -lmfr -leco -ldl -lm $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

mocktask:	mocktask_main.o libmock.a libmfr.a libeco.a libold.a libbridger.a
	@echo "LD	libmock.a"
	@$(CXX) -o mocktask mocktask_main.o -L. -lmock -lmfr -leco -lmfr -lold -lbridger -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide mocktask
endif
	
ft20: ft20.o libft20.a
	@echo "LD	$<"
	@$(CXX) -o  $@ $< -L. -lft20 -lold -lmfr -leco -lmfr -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide ft20
endif

libft20.a:	$(FT20_OBJS)
	@$(AR) rv $@ $^
	@echo "AR	$@ up to date"

librbg.a:	$(RBG_OBJS)
	@$(AR) rv $@ $^
	@echo "AR	$@ up to date"

libbridger.a:	$(BRIDGER_OBJS)
	@$(AR) rv $@ $^
	@echo "AR	$@"

libmock.a:	$(MOCKTASK_OBJS)
	@$(AR) rv $@ $^
	@echo "AR	$@"

lamkoord:	liblamkoord.a libold.a libmfr.a libeco.a
	@echo "LD	liblamkoord.a"
	@$(CXX) -o lamkoord -L. -llamkoord -lmfr -leco -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

rbg:	rbg_main.o librbg.a libold.a libmfr.a libeco.a
	@echo "LD	librbg.a"
	@$(CXX) -o rbg rbg_main.o -L. -lrbg -lmfr -leco -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

rooter:		librooter.a libmfr.a libeco.a libold.a
	@echo "LD	librooter.a"
	@$(CXX) -o rooter -L. -lrooter -lmfr -leco -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

sqlalert:	sqlalert.o libold.a libmfr.a libeco.a libbridger.a libmock.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lmfr -leco -lmock -lold -lmfr -lbridger -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

sqlpipe:	sqlpipe.o libold.a libmfr.a libeco.a libbridger.a libmock.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lmfr -leco  -lmock -lold -lmfr -lbridger -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

rbgkombmplus:	MfrObject.o RBGObject.o rbgkombmplus.o libold.a libmfr.a libeco.a
	@echo "LD	rbgkombmplus.o ..."
	@$(CXX) -o  rbgkombmplus rbgkombmplus.o RBGObject.o MfrObject.o -L. -lmfr -leco -lold -lmfr -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

#rbglam:		MfrObject.ob RBGObject.ob rbgkombmplus

#Delegate.o:		Delegate.h Delegate.cpp Delegate_impl.h
#	cc -g -Wall -Werror -O0 -pipe -DSANE -I/usr/include/libxml2 -c -o Delegate.o Delegate.cpp
#
#sandbox.o:	sandbox.cpp Delegate.o
#	cc -g -Wall -Werror -O0 -pipe -DSANE -I/usr/include/libxml2 -I$(ORACLE_HOME)/precomp/public/ -c -o sandbox.o sandbox.cpp
#
#sandbox:	sandbox.o
#	$(CXX) -o sandbox sandbox.o Delegate.o  -L. -lmfr -leco -lold -L$(ORACLE_HOME)/lib/ -lclntsh `cat $(ORACLE_HOME)/lib/ldflags`\
#	`cat $(ORACLE_HOME)/lib/sysliblist` -ldl -lm $(PROJLIBS)

dambach:	dambach.o libmfr.a libeco.a libold.a
	@echo "LD	$<"
	@$(CXX) -o dambach dambach.o -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

debug:	debug.o libmfr.a libeco.a libold.a
	@echo "LD	$<"
	@$(CXX) -o debug debug.o -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

l2all:	l2all.o libl2.a
	@echo "LD	$<"
	@$(CXX) -o l2all l2all.o -L. -ll2 cif/api/cif_api.o -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

l2get:	l2get.o
	@echo "LD	$<"
	@$(CXX) -o l2get l2get.o cif/api/cif_api.o -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

l2anford:	l2anford.o
	@echo "LD	$<"
	@$(CXX) -o l2anford l2anford.o -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

runscript:	runscript.o libeco.a libmfr.a libold.a
	@echo "LD	$<"
	@$(CXX) -o runscript runscript.o -L. -lmfr -leco -lold $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

##han
bridger:	bridger_main.o libbridger.a libmfr.a libeco.a libold.a
	@echo "LD	libbridger.a"
	@$(CXX) -o bridger bridger_main.o -L. -lbridger -lmfr -leco -lold $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

##han
telbuch:	telbuch.o libbridger.a libmfr.a libeco.a libold.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lold -lmfr -leco -lbridger -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

msg_read:	msg_read.o libold.a libmfr.a libeco.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

msg_remv:	msg_remv.o libold.a libmfr.a libeco.a
	@echo "LD	$<"
	@$(CXX) -o msg_remv msg_remv.o -L. -lold -lmfr -leco $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

progpaus:	progpaus.o libold.a libmfr.a libeco.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lold -lmfr -leco -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

readChannel:	readChannel.o libold.a libeco.a libmfr.a
	@echo "LD	$<"
	@$(CXX) -o $@ $< -L. -lmfr -leco -lold -leco -lmfr -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS) $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif


dumpConfig:	dumpConfig.o libmfr.a libeco.a libold.a
	@echo "LD	$<"
	@$(CXX) -o dumpConfig dumpConfig.o -L. -lmfr -leco -lold $(PROJLIBS)
ifndef CBASEFLAGS
	./provide $@
endif

ansidyn:	ansidyn1.o
	@echo "Linking ansidyn..." $<
	@$(CXX) -o ansidyn1 ansisyn1.o -L$(ORACLE_HOME)/lib/ -lclntsh

# ------------ Indivs --------------

stacker:	stacker.o stacker_aux.o libold.a
	$(CXX) -o stacker stacker.o stacker_aux.o -L. -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS)
ifndef CBASEFLAGS
	./provide $@
endif

ballma:		ballma.o ballma_init.o libold.a
	$(CC) -o ballma ballma.o ballma_init.o -L. -lold -L$(ORACLE_HOME)/lib/ $(ORALIBS)
ifndef CBASEFLAGS
	./provide $@
endif

hrlkamax: $(HRLKAMAX)/hrlkamax.pc libold.a libmfr.a libeco.a
	proc config=$(CONFIG) include=./ iname=$(HRLKAMAX)/hrlkamax.pc oname=hrlkamax.c
	cc -g -Wall -Werror -O0 -pipe -DSANE -I$(ORACLE_HOME)/precomp/public/   -c -o hrlkamax.ob hrlkamax.c
	rm hrlkamax.c
	$(CXX) -o  hrlkamax hrlkamax.ob -L. -lold -lmfr -leco -L$(ORACLE_HOME)/lib/ $(ORALIBS)
	cp hrlkamax $(HRLKAMAX)/
